package gameSocketer.socketSenders
{
	import com.adobe.crypto.MD5;
	import com.adobe.serialization.json.JSON;

	public class LoginSocketSender extends SocketSenderBase
	{
		/**MD5key*/
		private var key:Array = new Array("game","111","222","333","444");
		private var MD5key:int=0;
		
		public static var instance:LoginSocketSender;
		
		public function LoginSocketSender(loginKey:LoginKey)
		{
			super();
		}
		/**获取登陆socketer实例*/
		public static function getInstance():LoginSocketSender
		{
			instance||=new LoginSocketSender(new LoginKey());
			return instance;
		}
		
		/**1.0 请求登陆包*/
		public function askLoginPack():void{
//			sendData.writeByte(1);
//			sendData.writeByte(1);
//			sendData.writeByte(MD5key);
//			tempArray.length=8;
//			tempArray.writeMultiByte("12345678","utf-8");
//			sendData.writeBytes(tempArray);
//			sendData.writeMultiByte(MD5.hash("12345678"+key[MD5key]),"utf-8");
			sendData.writeByte(1);
			sendData.writeByte(0);
			
			socketer.send();
		}
		/**1.1 请求登陆加密包*/
		public function passwordEncryptPack(key:String):void{
//			MD5key=launch.readByte();
//			trace(Base.MD5key+"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
			sendData.writeByte(1);
			sendData.writeByte(1);
			
			tempObj = new Object();
			tempObj["account"] = BlackJack.loginUI.userId;
			tempObj["pwd"] = MD5.hash(BlackJack.loginUI.password + key);
			tempObj["key"] = key;
			
			sendData.writeUTFBytes(com.adobe.serialization.json.JSON.encode(tempObj));
			
			socketer.send();
		}
	}
}
class LoginKey{};